package com.ilovepostcard.view;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.ilovepostcard.R;

public class PostcardWidget extends RelativeLayout {
    
    private long pid;
    private ImageView mPostcard;
    private ImageView mCheckMark;
    private boolean mSelected;
    
    public PostcardWidget(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        inflate();
    }

    public PostcardWidget(Context context, AttributeSet attrs) {
        super(context, attrs);
        inflate();
    }

    public PostcardWidget(Context context) {
        super(context);
        inflate();
    }
    
    public void setPid(long pid) {
        this.pid = pid;
    }
    
    public long getPid() {
        return pid;
    }
    
    public void setPostcardImage(int res) {
        mPostcard.setImageResource(res);
    }
    
    public ImageView getPostcardImageView() {
        return mPostcard;
    }
    
    public void setSelected(boolean selected) {
        mSelected = selected;
        mCheckMark.setVisibility(selected ? VISIBLE : GONE);
    }

    private void inflate() {
        View view = View.inflate(getContext(), R.layout.postcard_widget, this);
        mPostcard = (ImageView) view.findViewById(R.id.postcard_image);
        mCheckMark = (ImageView) view.findViewById(R.id.postcard_check);
    }
    
}
